/**
 * 详情对话框
 */
var SrechargeInfoDlg = {
    data: {
        id: "",
        type: "",
        number: "",
        date:"",
        applicantId:"",
        remarks:"",
    }
};

layui.use(['form', 'admin', 'ax','layedit','table','upload'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var layedit = layui.layedit;
    var table = layui.table;
    var upload = layui.upload;

    //让当前iframe弹层高度适应
    admin.iframeAuto();

    //获取详情信息，填充表单
    var ajax = new $ax(Feng.ctxPath + "/srecharge/detail?id=" + Feng.getUrlParam("id"));
    var result = ajax.start();
    form.val('srechargeForm', result.data);

    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/srecharge/check", function (data) {
            Feng.success("审核成功！");
            window.location.href = Feng.ctxPath + '/srecharge'
        }, function (data) {
            Feng.error("更新失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });

    //返回按钮
    $("#backupPage").click(function () {
        alert(Feng.getUrlParam("id"));
        window.location.href = Feng.ctxPath + '/srecharge'
    });








    var Product = {
        tableId: "productTable"
    };

    //表格
    Product.initColumn = function () {
        return [[
            {field: 'id', hide: true, title: '申请人'},
            {field: 'userName', sort: true, title: '申请人'},
            {field: 'deptName', sort: true, title: '部门'},
            {field: 'type', sort: true, title: '充值类型'},
            {field: 'number', sort: true, title: '本次充值金额'},
            {field: 'date', sort: true, title: '申请日期'},
            {field: 'remarks', sort: true, title: 'remarks'},
            {align: 'center', toolbar: '#tableBar', title: '操作'}
        ]];
    };

    // 渲染表格
    var tableResult = table.render({
        elem: '#' + Product.tableId,
        url: Feng.ctxPath + '/srecharge/listCheck',
        page: true,
        height: "full-158",
        cellMinWidth: 100,
        cols: Product.initColumn()
    });







    var Product2 = {
        tableId: "productTable2"
    };

    //表格
    Product2.initColumn = function () {
        return [[
            {field: 'processInstanceId', hide: true, title: '流程id'},
            {field: 'userName', sort: true, title: '审核人'},
            {field: 'deptName', sort: true, title: '审核人部门'},
            {field: 'comment', sort: true, title: '审批意见'},
            {field: 'checkStr', sort: true, title: '审核状态'},
            {field: 'auditTime', sort: true, title: '审核时间'},
            {align: 'center', toolbar: '#tableBar', title: '操作'}
        ]];
    };

    // 渲染表格
    var tableResult2 = table.render({
        elem: '#' + Product2.tableId,
        url: Feng.ctxPath + '/srechargeOrderAudit/listCheck/'+$("#ids").val(),
        page: true,
        height: "full-158",
        cellMinWidth: 100,
        cols: Product2.initColumn()
    });


















});